Procedure muerte.es
	vida:=vida-1
	si vida=0 entonces
		Escribir ("Perdi")
		Escribir ("Desea continuar ingrese Y/N?")
		Leer (op)
		si op=Y entonces
			procedure menu.es
		sino
			{algn procedimiento para salir del juego y cerrar ventana}
		fin si
	fin si
fin procedure

Procedure menu.es
	Escribir ("Ingrese una opcin")
	Escribir (" 1: Comenzar juego
		    2: Instrucciones
		    3: opciones
		    4: salir         ")
	Leer (opmenu)
	segun opmenu hacer
		1: vida:=3, nivel:=1, procedure puerta.es
		2: { mostrar por pantalla las Instrucciones} 
		3: {llevar al men de opciones}
		4: {algn procedimiento para salir del juego y cerrar ventana}	
	fin segun.
fin procedure


procedure random.es
	var
	hs, min, seg, mil: word;
	begin 
		clrscr;
		getTime (hs,'.',min,'.',seg100)
		s:=mil
		s:= s div 10
	end;
fin procedure



procedure puerta.es
	{invocamos a procedimiento random}
	a:=S
	si a > 7 entonces
		a:= a-6
	fin si
	b:=a+1
	si b > 6 entonces
		b:= b-6
	fin si
	c:= b+1
	si c > 6 entonces
		c:= c-6
	fin si
	



case x of
1: BEGIN a:= 1,b:= 2, c:= 3,d:= 4,e:= 5,f:= 6 END;
2: a:= 2,b:= 3, c:= 4,d:= 5,e:= 6, f:= 1;
3: a:= 3,b:= 4, c:= 5,d:= 6,e:= 1, f:= 2;
4: a:= 3,b:= 4, c:= 5,d:= 6,e:= 1, f:= 2;
end;

IF x=1 then
           begin
                a:= 2;b:= 3; c:= 4;d:= 5;e:= 6; f:= 1;
           end;
           if x=2 then
           begin
           a:= 3;b:= 4; c:= 5;d:= 6;e:= 1; f:= 2;
           end;
           if x=3 then
           begin
           a:= 5;b:= 6; c:= 2;d:= 4;e:= 3; f:= 1;
           end;
           if x=4 then
           begin
           a:= 4;b:= 1; c:= 3;d:= 5;e:= 2; f:= 6;
           end;
           if x=5 then
           begin
           a:= 1;b:= 2; c:= 3;d:= 4;e:= 5; f:= 6;
           end;
           if x=6 then
           begin
           a:= 6;b:= 5; c:= 4;d:= 3;e:= 2; f:= 1;
           end;
           if x=7 then
           begin
           a:= 2;b:= 4; c:= 5;d:= 1;e:= 6; f:= 3;
           end;
           if x=8 then
           begin
           a:= 3;b:= 1; c:= 2;d:= 5;e:= 4; f:= 1;
           end;
           if x=9 then
           begin
           a:= 5;b:= 2; c:= 3;d:= 1;e:= 4; f:= 6;
           end;
           if x=10 then
           begin
           a:= 4;b:= 5; c:= 1;d:= 4;e:= 1; f:= 3;
           end;



--------------------------------------------------------------------------------------------------
program puertas;
var
nivel,x,a,b,c,d,e,f,y,vidas: integer;
z:CHAR;
BAND: BOOLEAN;

begin
vidas:=3;
nivel:=1;
randomize;

while (vidas <> 0) AND (nivel <=6) do
 begin
 x:=random (10) + 1;
 WRITE (X);
 BAND:=TRUE;

           IF x=1 then
           begin
                a:= 2;b:= 3; c:= 4;d:= 5;e:= 6; f:= 1;
           end;
           if x=2 then
           begin
           a:= 3;b:= 4; c:= 5;d:= 6;e:= 1; f:= 2;
           end;
           if x=3 then
           begin
           a:= 5;b:= 6; c:= 2;d:= 4;e:= 3; f:= 1;
           end;
           if x=4 then
           begin
           a:= 4;b:= 1; c:= 3;d:= 5;e:= 2; f:= 6;
           end;
           if x=5 then
           begin
           a:= 1;b:= 2; c:= 3;d:= 4;e:= 5; f:= 6;
           end;
           if x=6 then
           begin
           a:= 6;b:= 5; c:= 4;d:= 3;e:= 2; f:= 1;
           end;
           if x=7 then
           begin
           a:= 2;b:= 4; c:= 5;d:= 1;e:= 6; f:= 3;
           end;
           if x=8 then
           begin
           a:= 3;b:= 1; c:= 2;d:= 5;e:= 4; f:= 1;
           end;
           if x=9 then
           begin
           a:= 5;b:= 2; c:= 3;d:= 1;e:= 4; f:= 6;
           end;
           if x=10 then
           begin
           a:= 4;b:= 5; c:= 1;d:= 2;e:= 1; f:= 3;
           end;

write( 'seleccione entre las siguientes puertas');
writeln ('  A  B   C   D   E   F ');
read (z);

CASE Z OF
'A': y:= a;
'B': y:= b;
'C': y:= c;
'D': y:= d;
'E': y:= e;
'F': y:= f;
ELSE BAND:= FALSE;
END;
IF BAND THEN
BEGIN
CASE Y OF
1:vidas:=vidas-1;
2:nivel :=nivel+1;
3:if nivel <>1 then begin nivel := nivel-1 end;
6:if nivel <>1 then begin nivel := nivel-1 end;
end;


     CASE y OF
     1: WRITE ('PERDISTE, VIDAS=',vidas);
   2: WRITE ('GANASTE,PASAS AL NIVEL ,HABITACION, ',nivel);
   3: WRITE ('LA BARDIASTE, bajas un nivel, HABITACION, ',nivel);
   4: WRITE ('te mantienes en la misma habitacion, HABITACION ', nivel);
   5: WRITE ('te mantienes en la misma habitacion, HABITACION ',nivel);
   6: WRITE ('LA BARDIASTE, bajas un nivel, HABITACION ',nivel );
   END;

END;
READLN; READLN;
end;



end.


		
	